<template>
  <div>
    <el-dialog title="发起群聊" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="群聊昵称" :label-width="formLabelWidth">
          <el-input v-model="form.groupName" autocomplete="off" />
        </el-form-item>
        <el-form-item label="群成员" :label-width="formLabelWidth">
          <el-select
            v-model="form.groupMembers"
            multiple
            collapse-tags
            style="margin-left: 20px;"
            placeholder="请选择群成员"
          >
            <el-option label="区域一" value="shanghai" />
            <el-option label="区域二" value="beijing" />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="save">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { create } from '@/api/group/index'
import { mapGetters, mapState } from 'vuex'
export default {
  name: 'CreateGroup',
  data() {
    return {
      dialogFormVisible: false,
      form: {
        groupName: '',
        groupMembers: [],
        groupOwnerId: ''
      },
      formLabelWidth: '120px'
    }
  },
  computed: {
    ...mapState([
      'user'
    ])
  },
  methods: {
    changeStatus() {
      this.dialogFormVisible = true
    },
    save() {
      this.form.groupOwnerId = this.user.userId
      create(this.form)
      this.dialogFormVisible = false
    }
  }
}
</script>

<style scoped>

</style>
